import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/request")
public class HttpServletRequest extends HttpServlet {
    @Override
    protected void doGet(javax.servlet.http.HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println(req.getProtocol());
        System.out.println(req.getMethod());
        System.out.println(req.getRequestURI());
        System.out.println(req.getContextPath());
        System.out.println(req.getQueryString());
        Enumeration<String> headers = req.getHeaderNames();
        StringBuilder respBody = new StringBuilder();
        while (headers.hasMoreElements()) {
            String header = headers.nextElement();
            respBody.append(header + ": " + req.getHeader(header));
            respBody.append("<br>");
        }
        System.out.println(respBody.toString()
        );
    }
}
